package nige.capture;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class JPaneTransformation extends JPanel {
	
	public static Color[][] colorImage = null;
	
	public void update(Graphics g) {
		super.update(g);
	}
	
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		try {
			g.setColor(Color.black);
			for(int i=0;i<Maillage.points.size();i++) {
				Points p = (Points)Maillage.points.get(i);
				g.setColor(Color.blue);
				g.fillRect(p.xValue-1,p.yValue-1,3,3);
				g.setColor(p.colour);
				g.fillRect(p.xValue,p.yValue,1,1);
			}
			for(int i=0;i<Maillage.triangles.size();i++) {
				
				Triangles triag = (Triangles)Maillage.triangles.get(i);
				g.setColor(new Color(triag.getRed(),triag.getGreen(),triag.getBlue()));
				int[] xPoints = {
						triag.sommet1.xValue,triag.sommet2.xValue,
						triag.sommet3.xValue
					};
				int[] yPoints = {
						triag.sommet1.yValue,triag.sommet2.yValue,
						triag.sommet3.yValue
					};
				g.fillPolygon(xPoints, yPoints,3);
				
				g.setColor(Color.black);
				g.drawLine(
						triag.sommet1.xValue,
						triag.sommet1.yValue,
						triag.sommet2.xValue,
						triag.sommet2.yValue
						);
				g.drawLine(
						triag.sommet2.xValue,
						triag.sommet2.yValue,
						triag.sommet3.xValue,
						triag.sommet3.yValue
						);
				g.drawLine(
						triag.sommet3.xValue,
						triag.sommet3.yValue,
						triag.sommet1.xValue,
						triag.sommet1.yValue
						);
				 
			}
		}
		catch(Exception e) {
			System.out.println(e);
		}
	}
	
}
